﻿using System;
using System.Collections.Generic;
using System.Text;

namespace curbside.Messaging
{
    public class MessageQueueExHelper
    {
        /// <summary>
        /// 得到消息队列
        /// </summary>
        /// <param name="host">消息队列所在的主机名</param>
        /// <param name="queueName">消息队列名称</param>
        /// <returns></returns>
        public static MessageQueueEx<T> GetQueue<T>(string host, string queueName)
            where T : BaseMessage
        {
            string path = getQueuePath(host, queueName);
            MessageQueueEx<T> queue = new MessageQueueEx<T>(path);

            return queue;
        }

        /// <summary>
        /// 根据主机名，队列名称 获得队列路径
        /// </summary>
        /// <param name="hostname"></param>
        /// <param name="type"></param>
        /// <returns></returns>
        private static string getQueuePath(string hostname, string msgQueueName)
        {
            return string.Format(@"FormatName:DIRECT=OS:{0}\private$\{1}", hostname, msgQueueName);
        }
    }
}
